home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / Entity.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  4.3 KB  |  137 lines

  1. package symantec.itools.db.net;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.IOException;
  6. import java.util.Vector;
  7. import symjava.sql.SQLException;
  8.  
  9. public class Entity extends ServerObject {
  10.    Vector _attribs = new Vector();
  11.    int _count;
  12.    Vector _attribNames = new Vector();
  13.  
  14.    Entity() {
  15.    }
  16.  
  17.    int getType() {
  18.       return 64;
  19.    }
  20.  
  21.    void read(DataInputStream in) throws SQLException, IOException, ErrorException {
  22.       in.readShort();
  23.       this._count = in.readShort();
  24.       if (this._count > 0) {
  25.          ServerObject obj = (ServerObject)NetClass.getNextObject(in);
  26.          if (obj.getType() != 54) {
  27.             throw new SQLException("Object Stream error in Entity object");
  28.          }
  29.  
  30.          this._attribs = ((ServerList)obj).getObjVector();
  31.          this._count = this._attribs.size();
  32.          this._attribNames = new Vector(this._count);
  33.  
  34.          for(int i = 1; i <= this._count; ++i) {
  35.             this._attribNames.addElement(this.getColumnName(i));
  36.          }
  37.       }
  38.  
  39.    }
  40.  
  41.    void write(DataOutputStream out) throws IOException {
  42.       throw new IOException("Write not permitted on Entity object");
  43.    }
  44.  
  45.    Attribute getAttribute(int column) throws SQLException {
  46.       if (column >= 1 && column <= this._count) {
  47.          return (Attribute)this._attribs.elementAt(column - 1);
  48.       } else {
  49.          throw new SQLException("Column index out of range");
  50.       }
  51.    }
  52.  
  53.    public Vector getColumnList() throws SQLException {
  54.       return this._attribNames;
  55.    }
  56.  
  57.    public int getColumnCount() throws SQLException {
  58.       return this._count;
  59.    }
  60.  
  61.    public boolean isAutoIncrement(int column) throws SQLException {
  62.       return this.getAttribute(column).isAutoIncrement();
  63.    }
  64.  
  65.    public boolean isCaseSensitive(int column) throws SQLException {
  66.       return this.getAttribute(column).isCaseSensitive();
  67.    }
  68.  
  69.    public boolean isSearchable(int column) throws SQLException {
  70.       return this.getAttribute(column).isSearchable();
  71.    }
  72.  
  73.    public boolean isCurrency(int column) throws SQLException {
  74.       return this.getAttribute(column).isCurrency();
  75.    }
  76.  
  77.    public int isNullable(int column) throws SQLException {
  78.       return this.getAttribute(column).isNullable();
  79.    }
  80.  
  81.    public boolean isSigned(int column) throws SQLException {
  82.       return this.getAttribute(column).isSigned();
  83.    }
  84.  
  85.    public int getColumnDisplaySize(int column) throws SQLException {
  86.       return this.getAttribute(column).getColumnDisplaySize();
  87.    }
  88.  
  89.    public String getColumnLabel(int column) throws SQLException {
  90.       return this.getAttribute(column).getColumnLabel();
  91.    }
  92.  
  93.    public String getColumnName(int column) throws SQLException {
  94.       return this.getAttribute(column).getColumnName();
  95.    }
  96.  
  97.    public String getSchemaName(int column) throws SQLException {
  98.       return this.getAttribute(column).getSchemaName();
  99.    }
  100.  
  101.    public int getPrecision(int column) throws SQLException {
  102.       return this.getAttribute(column).getPrecision();
  103.    }
  104.  
  105.    public int getScale(int column) throws SQLException {
  106.       return this.getAttribute(column).getScale();
  107.    }
  108.  
  109.    public String getTableName(int column) throws SQLException {
  110.       return this.getAttribute(column).getTableName();
  111.    }
  112.  
  113.    public String getCatalogName(int column) throws SQLException {
  114.       return this.getAttribute(column).getCatalogName();
  115.    }
  116.  
  117.    public int getColumnType(int column) throws SQLException {
  118.       return this.getAttribute(column).getColumnType();
  119.    }
  120.  
  121.    public String getColumnTypeName(int column) throws SQLException {
  122.       return this.getAttribute(column).getColumnTypeName();
  123.    }
  124.  
  125.    public boolean isReadOnly(int column) throws SQLException {
  126.       return this.getAttribute(column).isReadOnly();
  127.    }
  128.  
  129.    public boolean isWritable(int column) throws SQLException {
  130.       return this.getAttribute(column).isWritable();
  131.    }
  132.  
  133.    public boolean isDefinitelyWritable(int column) throws SQLException {
  134.       return this.getAttribute(column).isDefinitelyWritable();
  135.    }
  136. }
  137.